package com.ruihui.activity;

import org.mybatis.spring.annotation.MapperScan;
import org.redisson.Redisson;
import org.redisson.config.Config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;

@MapperScan("com.ruihui.activity.mapper")
@EnableEurekaClient
@SpringBootApplication
@EnableRedisHttpSession
//@EnableTransactionManagement
public class ActivityApp {
	public static void main(String[] args) {
		SpringApplication.run(ActivityApp.class, args);
	}
	
	@Bean
	@LoadBalanced
	RestTemplate restTemplate() {
		RestTemplate restTemplate = new RestTemplate();
//        restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
        return restTemplate;
	}
//	@Bean
//    Redisson redissonSentinel() {
//        //支持单机，主从，哨兵，集群等模式
//        //此为哨兵模式
//        Config config = new Config();
//        config.useSentinelServers()
//                .setMasterName("mymaster")
//                .addSentinelAddress("redis://192.168.1.10:6379")
//                .setPassword("");
//        return (Redisson)Redisson.create(config);
//    }
	@Bean
    Redisson redissonSentinel() {
        //支持单机，主从，哨兵，集群等模式
        //此为单机模式
        Config config = new Config();
        config.useSingleServer()
                .setAddress("192.168.1.10:6379");
        return (Redisson)Redisson.create(config);
    }
	

}
